/*
 * File:   ThreadTable.h
 * Author: henrya
 *
 * Created on June 29, 2009, 6:53 AM
 */

#ifndef _THREADTABLE_H
#define	_THREADTABLE_H
#include <vector>
#include <string>
using std::vector;
using std::string;

class ThreadTable {
public:
    enum ThreadStatus {READY, RUNNING , BLOCKED};
private:
    vector<int> allNodeIds;
    ThreadStatus* status;
    int* accumulatedQuanta;
    int* lastQuanta;
    int* usedQuanta;
    int* priority;
    int* accUsedQuanta;
private:
    unsigned int indexOf(int nodeId);
    string* getStatusString(ThreadStatus status);
public:
    ThreadTable(vector<int>* allNodeIds);
    virtual ~ThreadTable();
    int getUsedQuanta(int nodeId);
    void updateUsedQuanta(int nodeId, int currQuanta);
    ThreadStatus getStatus(int nodeID);
    void setStatus(int nodeId, ThreadStatus status);
    int getAccumulatedQuanta(int nodeId);
    void addQuanta(int nodeId, int quanta);
    void setPriority(int nodeId, int priority);
    int getPriority(int nodeId);
    int getTotalAccumulatedQuanta();
    string* getThreadTableString();
};

#endif	/* _THREADTABLE_H */

